import {request} from './request'

// 购物车
export function addCart(data) {
    return request({
        url: '/api/carts',
        method: 'post',
        data
    })
}

// 修改购物车 data={num:1}
export function editCart(id, data) {
    return request({
        url: `/api/carts/${id}`,
        method: 'put',
        data
    })
}

// 购物车商品选中状态checked,data:所有选中的商品ID
export function checkedCart(data) {
    return request({
        url: '/api/carts/checked',
        method: 'patch',
        data
    })
}

// 获取购物车列表
export function getCarts(data = '') {
    return request({
        url: `/api/carts?${data}`,// api/carts?include=goods
        method: 'get',
    })
}

// 删除购物车
export function delCart(id) {
    return request({
        url: `/api/carts/${id}`,
        method: 'delete',
    })
}